package com.example.springboot.prop;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 *
 * <p> @Value取值，只支持从默认的配置文件中获取属性。
 *      支持直接注入、支持 SpEL 表达式。
 * @author Zhang.Z
 * @version 2025-09-19
 */
@Component
public class ValueConfigure {

    //从配置文件中取值
    @Value("${dept.id}")
    private Long deptId;

    //支持spEl表达式  例如"#{'${nats.url}'.split(',')}" 获取集合
    @Value("${dept.name:#{null}}")
    private String deptName;

    //直接注入字符串
    @Value("hello world")
    private String desc;

    private Integer member;

    private String deptCode;

    @Value("#{2 * 3}")
    private Integer v;

//    public ValueConfigure() {
//
//    }


    public ValueConfigure(@Value("${dept.code}")String deptCode) {
        this.deptCode = deptCode;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Integer getMember() {
        return member;
    }

    @Value("${dept.member}")
    public void setMember(Integer member) {
        this.member = member;
    }

    public String getDeptCode() {
        return deptCode;
    }


    public void setDeptCode(String deptCode) {
        this.deptCode = deptCode;
    }

    public Integer getV() {
        return v;
    }

    public void setV(Integer v) {
        this.v = v;
    }
}
